package io.renren.modules.jxgkteacher.controller;


import io.renren.modules.jxgkteacher.entity.TeacherCourseEntity;
import io.renren.modules.jxgkteacher.service.TeacherCourseService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;

@RestController
@RequestMapping("/TeacherCourse")
public class TeacherCourseController {
    @Autowired
    TeacherCourseService teacherCourseService;
    @RequestMapping("/Week")
    public List<TeacherCourseEntity> findTeacherWeekCourseById(@RequestBody Map<String,String> param){

        List<TeacherCourseEntity> tce= teacherCourseService.FindTeacherWeekCourseById(param.get("teacherId"),
                                                                param.get("courseAcademicYear"),
                                                                param.get("courseAcademicTerm"),
                                                                param.get("courseWhichWeek"));
        return tce;
    }
    @RequestMapping("/Day")
    public List<TeacherCourseEntity> findTeacherDayCourseById(@RequestBody Map<String,String> param){
        List<TeacherCourseEntity> tce= teacherCourseService.FindTeacherWeekCourseById(param.get("teacherId"),
                param.get("courseAcademicYear"),
                param.get("courseAcademicTerm"),
                param.get("courseWhichWeek"));
        List<TeacherCourseEntity> result=new ArrayList<>();
        for(TeacherCourseEntity temp:tce){
            if(temp.getCourseWhichDay().equals(param.get("courseWhichDay")))
                result.add(temp);
        }
        return result;
    }
}
